﻿Partial Class NorthwindDataSet
    Partial Class ProductsDataTable

        Private Sub ProductsDataTable_ColumnChanging(ByVal sender As Object, ByVal e As System.Data.DataColumnChangeEventArgs) Handles Me.ColumnChanging
            If e.Column.ColumnName = "UnitsInStockColumn" Then
             
                If Convert.ToInt16(e.ProposedValue) <= 0 Then
                    e.Row.SetColumnError(e.Column, "The value is negative")
                Else
                    e.Row.SetColumnError(e.Column, String.Empty)
                End If
            End If

        End Sub

        Private Sub ProductsDataTable_RowChanged(ByVal sender As Object, ByVal e As System.Data.DataRowChangeEventArgs) Handles Me.RowChanged
            If e.Row.Item("UnitsInStock") < 1 And e.Row.Item(UnitsOnOrderColumn) < 10 Then
                e.Row.RowError = "The units on order are very low"
            Else
                e.Row.RowError = String.Empty

            End If


        End Sub

        Private Sub ProductsDataTable_TableNewRow(ByVal sender As Object, ByVal e As System.Data.DataTableNewRowEventArgs) Handles Me.TableNewRow
            e.Row.Item(UnitPriceColumn) = 0

        End Sub
    End Class

End Class
